package com.muse.app.dao;

import com.muse.entity.UserInfo;
import com.muse.sqlutils.SqlBuilder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import static com.muse.sqlutils.SqlBuilder.and;
import static com.muse.sqlutils.SqlBuilder.eq;

/**
 * Created with IntelliJ IDEA.
 * User: lee
 * Date: 2021/4/22
 * Time: 3:40 下午
 * Description:
 */
@Repository
@Slf4j
public class UserDao {
    @Autowired
    private JdbcTemplate jdbcTemplate;

    public UserInfo getUserInfoByPhone(String phone) {
        return SqlBuilder.select("t_user")
                .where(
                        eq("phone", phone)
                ).queryForObject(jdbcTemplate, UserInfo.class, null);
    }

    public UserInfo getUserInfoById(int id) {
        return SqlBuilder.select("t_user")
                .where(
                        eq("id", id)
                ).queryForObject(jdbcTemplate, UserInfo.class, null);
    }
}
